import getApiData from "@/services/cpasRequest";
import notify from 'devextreme/ui/notify';



// 获取指定账套ID的科目的节点的上级节点
export async function getSubjectParentList(params: {
  dbname: string;
  Data_ID: string;
  PKMBH: string;
}) {
  const res = await getApiData("account.subject.getDataParentList", params);
  return Promise.resolve({
    data: res.data,
    success: res.ok,
  });
}

// 删除科目
export async function SubjectDel(params: {
  dbname: string;
  Data_ID: string;
  editUser: string | undefined;
  KMBH: string;
}) {
  const res = await getApiData("account.subject.del", params);
  return res;
}

// 删除辅助账
export async function AssistDel(params: {
  dbname: string;
  Data_ID: string;
  KMBH: string;
  editUser: string | undefined;
  HSXMLXBH: any;
  HSXMBH: string;
}) {
  const res = await getApiData("account.assist.del", params);
  return res;
}


// 获取辅助账的核算项目类型
export async function AssistgetType(params: {
  dbname: string;
  Data_ID: string;
  KMBH: string;
}) {
  const res = await getApiData("account.assist.getType", params);
  if (res.ok) {
    return res.data;
  }
  return []
}


// 增加辅助账
export async function AssistAdd(params: {
  dbname: string;
  Data_ID: string;
  KMBH: string;
  KMMC: string;
  editUser: string | undefined;
  HSXMLXBH: string;
  YSKMBH: any;
  HSXMLXMC: string;
  HSXMBH: string;
  HSXMMC: string;
  YSHSXMMC: string;
  YSHSXMBH: any
}) {
  const res = await getApiData("account.assist.add", params);
  return res;
}

// 编辑辅助账
export async function AssistEdit(params: {
  dbname: string;
  Data_ID: string;
  KMBH: string;
  KMMC: string;
  editUser: string | undefined;
  HSXMLXBH: string;
  YSKMBH: any;
  HSXMLXMC: string;
  HSXMBH: string;
  HSXMMC: string;
  YSHSXMMC: string;
  YSHSXMBH: any
}) {
  const res = await getApiData("account.assist.edit", params);
  if (res.ok) return res.ok
}

// 获取科目是否存在辅助账
export async function SubjectIsHasFZZ(params: {
  dbname: string;
  Data_ID: string;
  KMBH: string;
}) {
  const res = await getApiData("account.subject.isHasFZZ", params);
  if (res.ok) return res.data
}

// 是否可以增加辅助账
export async function IsCanAddFZZ(params: {
  dbname: string;
  Data_ID: string;
  KMBH: string;
}) {
  const res = await getApiData("account.subject.isCanAddFZZ", params);
  if (res.ok) return res.data
}

// 自动增加下级辅助账
export async function AutoAddChildrenForFZZ(params: {
  dbname: string;
  Data_ID: string;
  KMBH: string;
  editUser: string;
}) {
  const res = await getApiData("account.subject.autoAddChildrenForFZZ", params);
  if (res.ok) return res.data
}

// 获取一个新科目编号
export async function getNewKMBH(params: {
  dbname: string;
  Data_ID: string;
  KMBH: string;
}) {
  const res = await getApiData("account.subject.getNewKMBH", params);
  return res;
}


// 增加科目
export async function Addsubject(params: {
  dbname: string;
  Data_ID: string;
  KMBH: string;
  KMMC: string;
  editUser: string;
  PKMBH: string;
  YSKMBH: any;
  YSKMMC: string;
  KMFX: string;
  KMLX: string;
  JC: any;
  itemNames: string
}) {
  const res = await getApiData("account.subject.add", params);
  return res;
}


// 修改科目
// "dbname": "FI-2017-00001",
// "Data_ID": "2017",
// "KMBH": "1002~|06~|",
// "KMMC": "银行存款-修改科目测试",
// "editUser": "陆丽",
// "YSKMMC": "修改科目测试",
// "KMFX": "贷",
// "KMLX": "负债",
// "itemNames": "作七家来时治很"
export async function Editsubject(params: {
  dbname: string;
  Data_ID: string;
  KMBH: string;
  KMMC: string;
  editUser: string;
  YSKMMC: string;
  KMFX: string;
  KMLX: string;
  itemNames: string
}) {
  const res = await getApiData("account.subject.edit", params);
  return res;
}




